<?php

namespace App\Service;

use App\Constants\ErrorCode;
use App\Model\Industry;
use Hyperf\Snowflake\IdGeneratorInterface;
use Hyperf\Utils\ApplicationContext;
use Psr\Container\ContainerInterface;
use Hyperf\Di\Annotation\Inject;

class IndustryService extends BaseService
{

    public function insert(array $insertData)
    {
        return Industry::query()->insert($insertData);
    }

    public function insertGetId(array $insertData)
    {
        return Industry::query()->insertGetId($insertData);
    }

    public function update(array $upData)
    {
        return Industry::query()->where('id', $upData['id'])->update($upData);
    }


    /**
     * @param int $id
     * @param array $fields
     * @return array
     */
    public function getIndustryArrayById(int $id, array $fields = []): array
    {
        $dc = $this->getModelInstance()->where(['id' => $id])->select($fields)->get();
        return empty($dc) ? [] : $dc->toArray();
    }

    /**
     * @param array $id
     * @param array $fields
     * @return array
     */
    public function getIndustryArrayByIds(array $id, array $fields = ['*']): array
    {
        $dc = $this->getModelInstance()->whereIn('id', $id)->select($fields)->get();
        return empty($dc) ? [] : $dc->toArray();
    }

}